<script>
//图表标题配置
import BaseConfig from '../BaseConfig';
import * as ConfigEnum from '../config/config-enum';

export default {
  name: 'LegendConfig',
  mixins: [BaseConfig],
  data() {
    return {
      topBottomPos: ConfigEnum.TOP_BOTTOM_POSTION, //图例上下位置枚举
      leftRightPos: ConfigEnum.LEFT_RIGHT_POSITION, //图例左右位置枚举
      textAlign: ConfigEnum.TEXT_ALIGN, //图例文本方向枚举
      orientAlign: ConfigEnum.ORIENT_ALIGN, //图例布局朝向枚举
    };
  },
};
</script>

<template>
  <div>
    <Row>
      <Col span="8">
      <span>显示图例：</span>
      </Col>
      <Col span="16">
      <Switch
        v-model="chartOptions.extend.legend.show"
        @on-change="updateOptions">
        <span slot="open">是</span>
        <span slot="close">否</span>
      </Switch>
      </Col>
    </Row>
    <div
      v-if="chartOptions.extend.legend.show"
      class="switch-box">
      <Row>
        <Col span="8">
        <span>字体大小：</span>
        </Col>
        <Col span="16">
        <InputNumber
          v-model="chartOptions.extend.legend.textStyle.fontSize"
          :min="1"
          @on-change="updateOptions"></InputNumber>
        </Col>
      </Row>
      <Row>
        <Col span="8">
        <span>字体颜色：</span>
        </Col>
        <Col span="16">
        <ColorPicker
          v-model="chartOptions.extend.legend.textStyle.color"
          alpha
          @on-change="updateOptions"></ColorPicker>
        </Col>
      </Row>
      <Row>
        <Col span="8">
        <span>上下位置：</span>
        </Col>
        <Col span="16">
        <Select
          v-model="chartOptions.extend.legend.top"
          @on-change="updateOptions">
          <Option
            v-for="item in topBottomPos"
            :value="item.value"
            :key="item.value">{{ item.key }}</Option>
        </Select>
        </Col>
      </Row>
      <Row>
        <Col span="8">
        <span>左右位置：</span>
        </Col>
        <Col span="16">
        <Select
          v-model="chartOptions.extend.legend.left"
          @on-change="updateOptions">
          <Option
            v-for="item in leftRightPos"
            :value="item.value"
            :key="item.value">{{ item.key }}</Option>
        </Select>
        </Col>
      </Row>
      <Row>
        <Col span="8">
        <span>文本对齐：</span>
        </Col>
        <Col span="16">
        <Select
          v-model="chartOptions.extend.legend.align"
          @on-change="updateOptions">
          <Option
            v-for="item in textAlign"
            :value="item.value"
            :key="item.value">{{ item.key }}</Option>
        </Select>
        </Col>
      </Row>
      <Row>
        <Col span="8">
        <span>布局朝向：</span>
        </Col>
        <Col span="16">
        <Select
          v-model="chartOptions.extend.legend.orient"
          @on-change="updateOptions">
          <Option
            v-for="item in orientAlign"
            :value="item.value"
            :key="item.value">{{ item.key }}</Option>
        </Select>
        </Col>
      </Row>
    </div>
  </div>
</template>

<style>
</style>
